#!/bin/bash

echo "========================================"
echo "   3D资源分享站 - 前端开发环境启动"
echo "========================================"
echo

echo "正在检查Node.js环境..."
if ! command -v node &> /dev/null; then
    echo "❌ 错误: 未检测到Node.js，请先安装Node.js"
    exit 1
fi

echo "✅ Node.js环境正常"
echo

echo "正在检查依赖包..."
if [ ! -d "node_modules" ]; then
    echo "📦 正在安装依赖包..."
    npm install
    if [ $? -ne 0 ]; then
        echo "❌ 依赖包安装失败"
        exit 1
    fi
else
    echo "✅ 依赖包已存在"
fi

echo
echo "🚀 启动开发服务器..."
echo "📱 前端地址: http://localhost:80"
echo "🔧 后端地址: http://localhost:4112"
echo
echo "请确保后端服务已启动在端口4112"
echo

npm run dev
